package com.zdsoft.crm.dao.clue.echarts;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.zdsoft.crm.vo.clue.echarts.ClueCreateEChartsVo;
import com.zdsoft.crm.vo.clue.echarts.ClueDateEChartsVo;

public interface IEChartsMapper {

	/**
	 * 全部统计（按本星期）
	 * @param firstDayOfWeek
	 * @param lastDayOfWeek
	 * @return
	 */
	@Select("select to_char(c.CREATE_TIME,'yyyy-mm-dd') dateOfContract,count(c.id) numCount from CLUE c "
			+ "where c.CREATE_TIME >= to_date(#{firstDayOfWeek},'yyyy-MM-dd') "
			+ "and c.CREATE_TIME <=  to_date(#{lastDayOfWeek},'yyyy-MM-dd') " + "group by to_char(c.CREATE_TIME,'yyyy-mm-dd')")
	public List<ClueDateEChartsVo> EChartsDate(@Param("firstDayOfWeek") String firstDayOfWeek,
			@Param("lastDayOfWeek") String lastDayOfWeek);

	/**
	 * 全部统计（按时间）
	 */
	@Select("select  to_char(c.CREATE_TIME,'yyyy-mm-dd') dateOfContract,count(c.id) numCount from CLUE c "
			+ "group by  to_char(c.CREATE_TIME,'yyyy-mm-dd')")
	public List<ClueDateEChartsVo> EChartsDateAll();
	
	/**
	 * 全部统计（按创建人）
	 */
	@Select("select u.username createName,count(u.id) numCount from CLUE c "
			+ "left join SYS_USER u on c.CREATE_USER_ID = u.id group by u.username")
	public List<ClueCreateEChartsVo> EChartsCreate();
	
	
	
}
